<?php 

function option($items, $parent_id, $cat_id, $level=0) {
    foreach ($items as $item) {
        if ($item['id']==$cat_id) continue;
        
        $selected = ($item['id']==$parent_id) ? 'selected' : '';
        echo '<option value="'.$item['id'].'" '.$selected.'>';
        echo str_repeat('├─', $level).$item['name'];
        if (isset($item['children']) && is_array($item['children'])) {
            option($item['children'], $parent_id, $cat_id, $level+1);
        }
        echo '</option>';
    }
}
?>
<style>
.max-line1 {
    text-overflow: -o-ellipsis-lastline;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;	
}
.max-line2 {
    text-overflow: -o-ellipsis-lastline;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
</style>
<style>
.media-body .summary {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
	text-overflow: ellipsis;
    overflow: hidden;
}
.media-list img {width: 200px;}
@media (max-width: 425px)  {
    .media-list img {width: 115px;}	
    .media-body .summary {display: none;}
}
</style>

<h3 class="page-header">人才列表 
<a href="<?= URL::site('personInfo/add');?>" class="ajax-click">+</a>
</h3>

<form class="form-inline ajax-submit" method="get">

	<div class="form-group">
        <select class="form-control" name="status">
			<option value="">选择状态</option>
			<option value="1" <?php if(Arr::get($_GET, 'status')==1):?>selected<?php endif;?>>有档期</option>
			<option value="2" <?php if(Arr::get($_GET, 'status')==2):?>selected<?php endif;?>>无档期</option>
        </select>
    </div>
    
    
    
	
    <div class="form-group">
        <select class="form-control" name="cid">
			<option value="">选择分类</option>
			<?php if(Arr::get($_GET, 'pid')):?>
			<?php option($cat_tree, Arr::get($_GET, 'pid'), 0);?>
			<?php else:?>
			<?php option($cat_tree, $info['cid'], $info['id']);?>
			<?php endif;?>		
        </select>
    </div>
    <div class="form-group">
        <div class="input-group">
            <input type="text" class="form-control" name="name" value="<?php echo Arr::get($_GET, 'name')?>" placeholder="">
            <span class="input-group-btn">
                <button class="btn btn-info" type="submit">查找</button>
            </span>
        </div>
     </div>
</form>
<br>

<ul class="media-list">

<?php foreach($list as $item): ?>
<?php if (!empty($item['cid'])):?>
    <li class="media">
        <div class="media-left">
            <?php if (strpos($item['pic'], '://') !== false):?>
                <a href="<?= URL::site('personInfo/details?id='.$item['id']);?>">
            <?= HTML::image($item['pic'].'?imageView2/2/w/160/h/120') ?>
                </a>
            <?php else:?>
            <a href="<?= URL::site('personInfo/details?id='.$item['id']);?>">
            <?= HTML::image('http://jtkj.oss-cn-beijing.aliyuncs.com/article/20180625/6H6AFiXcJz.jpg ?imageView2/2/w/160/h/120') ?>
            </a>
            <?php endif;?>
        </div>

        <div class="media-body">
            <h4 class="media-heading"><?= $item['nick_name'] ?></h4>
            <p class="text-muted summary">
            <?php if (!empty($item['person_cate_name'])):?>
      	 		<?= $item['person_cate_name'][0] ?>
      	 		<?php if(!empty($item['person_cate_name'][1])):?>
      	 		<?= $item['person_cate_name'][1] ?>
      	 		<?php endif;?>
  	 		<?php else:?>
  	 			未定义
  	 		<?php endif;?>
            (<?= $item['city'] ?>)</p>
            <p class="text-muted summary">真名:<?= $item['real_name'] ?></p>
            <p class="text-muted summary">工作年限:<?= $item['work_year'] ?>年</p>
            <p class="text-muted summary">作&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;品:<?php foreach ($works as $work):?> <?php if ($work['user_id']==$item['uid']):?> <?= '《'.$work['name'].'》' ?> <?php endif;?> <?php endforeach;?></p>
            <p class="text-muted summary">薪&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;资:<?= $item['price'] ?>元/天</p>
            
          	<?php if ($item['status']==1):?>
            <a href="<?= URL::site('personInfo/close?id='.$item['id']);?>" class="btn btn-info btn-xs ajax-update">有档期</a>
            <?php else:?>
            <a href="<?= URL::site('personInfo/open?id='.$item['id']);?>" class="btn btn-danger btn-xs ajax-update">无档期</a>
            <?php endif;?>
            
            <?php if (isset($item['is_check_info'])):?>
            <span class="btn btn-info btn-xs ajax-update">已审核</span>
            <?php else:?>
            <span class="btn btn-danger btn-xs ajax-update">未审核</span>
            <?php endif;?>
            
    	     <a href="<?= URL::site('personInfo/addworks')?>?id=<?= $item['id'] ?>" class="btn btn-info btn-xs ajax-click">添加作品</a>
        </div>
    </li>
<?php else :?>
	<li class="media">
        <div class="media-left">
            
        </div>
        
        <div class="media-body">
            <h4 class="media-heading">请完善信息</h4>
            
          	<?php if ($item['status']==1):?>
            <a href="<?= URL::site('personInfo/close?id='.$item['id']);?>" class="btn btn-info btn-xs ajax-update">有档期</a>
            <?php else:?>
            <a href="<?= URL::site('personInfo/open?id='.$item['id']);?>" class="btn btn-danger btn-xs ajax-update">无档期</a>
            <?php endif;?>
            
            <?php if (isset($item['is_check_info'])):?>
            <span class="btn btn-info btn-xs ajax-update">已审核</span>
            <?php else:?>
            <span class="btn btn-danger btn-xs ajax-update">未审核</span>
            <?php endif;?>
<!--    	    <a href="--><?//= URL::site('personInfo/edit')?><!--?id=--><?//= $item['id'] ?><!--" class="btn btn-info btn-xs ajax-click">修改</a>-->
    	    
    	     <a href="<?= URL::site('personInfo/addworks')?>?id=<?= $item['id'] ?>" class="btn btn-info btn-xs ajax-click">添加作品</a>
        </div>
    </li>
<?php endif;?>
<?php endforeach; ?>
</ul>

<?= $pager ?>
